var path = require("path");
var fs = require("fs");
var entry = fs.readFileSync(path.join(__dirname, "entryList.json"), "utf-8");
var webpack = require("webpack");

module.exports = {
    entry: resetPath(entry),
    output: {
        path: path.join(__dirname, "/dist/js"),
        filename: "[name].bundle.js"
    },
    module: {
        loaders: [
            { test: /\.scss/, loader: "style!css!sass" },
            { test: /\.tpl/, loader: "raw"},
            { test: /\.json/, loader: "raw"}
        ]
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin("common.js"),
    ]
};

function resetPath(json){
    var rowJSON = JSON.parse(json);
    for(var i in rowJSON){
        rowJSON[i] = path.join(__dirname, "/src/js", rowJSON[i]);
    }
    return rowJSON;
}